package com.sright.bcard.user.biz.service;

import com.sright.bcard.common.service.share.dto.LoginUser;
import com.sright.bcard.common.service.share.dto.pager.Pager;
import com.sright.bcard.common.service.share.dto.request.VisitorPageRequest;
import com.sright.bcard.common.service.share.dto.response.VisitorPageResponse;
import com.sright.bcard.user.share.request.AnalysisListParam;
import com.sright.bcard.user.biz.manager.VisitorManager;
import com.sright.bcard.user.share.request.AddVisitorParamRequest;
import com.sright.bcard.user.share.service.VisitorService;
import com.sright.common.response.SrightResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

@Component
@Slf4j
public class VisitorServiceImpl implements VisitorService {

    @Autowired
    private VisitorManager visitorManager;

    @Override
    public SrightResponse getVisitorRanking(LoginUser loginUser) {
        return visitorManager.getVisitorRanking(loginUser);
    }

    @Override
    public SrightResponse getVisitorOverview(LoginUser loginUser) {
        return visitorManager.getVisitorOverview(loginUser);
    }

    @Override
    public SrightResponse parentRelationship(Long id) {
        return SrightResponse.defaultSuccess(visitorManager.parentRelationship(id));
    }

    @Override
    public SrightResponse childrenRelationship(Long id) {
        return SrightResponse.defaultSuccess(visitorManager.childrenRelationship(id));
    }

    @Override
    public SrightResponse recordVisitor(AddVisitorParamRequest addVisitorParamRequest, HttpServletRequest request) throws Exception {
        return SrightResponse.defaultSuccess(visitorManager.addVisitor(addVisitorParamRequest,request));
    }

    @Override
    public SrightResponse recordAccessTime(Long recordId, Integer time) {
        return SrightResponse.defaultSuccess(visitorManager.recordAccessTime(recordId,time));
    }

    @Override
    public SrightResponse<Pager<VisitorPageResponse>> pageVisitorList(VisitorPageRequest visitorPageRequest) {
        return SrightResponse.defaultSuccess(visitorManager.pageVisitorList(visitorPageRequest));
    }

    @Override
    public SrightResponse visitorAnalysisList(AnalysisListParam analysisListParam) {
        return visitorManager.visitorAnalysisList(analysisListParam);
    }

    @Override
    public void dataPushDay() throws Exception {
        visitorManager.dataPushDay();
    }
}
